﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using HotelManagement._04.OBJECT;
using HotelManagement._03.DAO;

namespace HotelManagement._02.BUS
{
    class PaymentBUS
    {
        PaymentDAO m_PaymentDAO = new PaymentDAO();
        public DataTable ViewPayment()
        {
            return m_PaymentDAO.ViewPayment("pr_tblCheckIn_SelectForPayment");
        }

        public DataTable ViewBill(string ip_InvoidNumber)
        {
            return m_PaymentDAO.ViewBill(ip_InvoidNumber, "pr_rptBill");
        }

        public DataTable ViewService(int ip_CustomerID)
        {
            return m_PaymentDAO.ViewService(ip_CustomerID, "pr_tblCustomerService_SelectForPayment");
        }

        public bool PaymentCheckInUpdate(Payment ip_Payment)
        {
            return m_PaymentDAO.UpdateCheckIn(ip_Payment, "pr_tblCheckIn_PaymentCheckInUpdate");
        }

        public bool UpdateCustomerService(int ip_CustomerServiceID)
        {
            return m_PaymentDAO.UpdateCustomerService(ip_CustomerServiceID, "pr_tblCustomerService_PaymentCheckInUpdate");
        }

        public bool InsertPayment(Payment ip_Payment)
        {
            return m_PaymentDAO.InsertPayment(ip_Payment, "pr_tblPayment_Insert");
        }

        public DataTable GetCheckInByCustomerIdAndDatetime(int ip_CustomerID, DateTime ip_date)
        {
            return m_PaymentDAO.GetCheckInByCustomerIdAndDatetime(ip_CustomerID, ip_date, "tbl_CheckIn_CountCheckInByCustomerIDAndDatetime");
        }

        public int CheckInvoidNumber()
        {
            DataTable v_dt = m_PaymentDAO.CheckInvoidNumber("pr_tblPayment_SearchInvoidNumber");
            if (v_dt.Rows.Count > 0)
            {
                return int.Parse(v_dt.Rows[0]["InvoidNumber"].ToString()) + 1;
            }
            return 1;
        }

        public DataTable SelectForPaymentByCustomerName(string ip_CustomerName)
        {
            return m_PaymentDAO.SelectForPaymentByCustomerName(ip_CustomerName, "pr_tblCheckIn_SelectForPaymentByCustomerName");
        }
    }
}
